package com.shiyang.decorator.mydecorator;

import com.shiyang.decorator.mycoffee.Drink;

/**
 * @author shiyang date: 2020/9/11
 */
public class Decorator extends Drink {

    // 被装饰者
    protected Drink obj;

    // 组合关系
    public Decorator(Drink obj) {
        this.obj = obj;
    }

    @Override
    public float cost() {
        // this.getPrice 该调料自己的价格
        // return super.getPrice() + obj.getPrice();
        return this.price + obj.cost();
    }

    @Override
    public String getDes() {
        return this.des + " : " + this.price + " && " + obj.getDes();
        // return super.getDes() + " : " + super.getPrice() + " && " + obj.getDes();
    }
}
